<template>
  <div class="page">
    <div class="layui-fluid">
      <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
          <div class="layui-card">
            <div class="layui-card-body">
              <div class="layui-form" lay-filter>

                <div class="layui-form-item">
              <div class="layui-inline">
                <label class="layui-form-label">PV分润总值</label>
                <div class="layui-input-inline">
                  <input
                    type="text"
                    name
                    v-model="itemData.amountlimit"
                    placeholder
                    autocomplete="off"
                    class="layui-input"
                  />
                </div>
                <div class="layui-form-mid">%</div>
                <div class="layui-form-mid layui-word-aux">PV分润比例,如10表示10%</div>
              </div>
            </div>


                <div class="layui-form-item">
                  <div class="layui-input-block">
                    <button class="layui-btn" @click="save()" lay-submit lay-filter="formDemo">确认</button>
                  </div>
                </div>
                <!--// -->
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Tables from "../common/tables.vue";
import Search from "../common/search.vue";
export default {
  name: "shoptype",
  components: { Tables, Search },
  data() {
    return {
      itemData: {}, //设置回选
      type: localStorage.getItem("type"),
    };
  },
  mounted() {
    var _this = this;
    window.getdates = this.getdates;
  },
  methods: {
    getdates: function (data) {
      var _this = this;
      _this.id = data.id;
      if(_this.type == '1'){
        var url = "/profit/aapi/v1.9/platformp-rofit/" + _this.id;
      }else{
        var url = "/profit/bapi/v1.9/platformp-rofit/" + _this.id;
      }
      //alert(url+"//"+JSON.stringify(dates))
      ajaxRequest(url, "GET", "json", "", function (ret, err) {
        _this.itemData = ret.data;
      });
    },
    save: function () {
      var _this = this;
      if (_this.type == "1") {
        var url = "/profit/aapi/v1.9/platformp-rofit/";
      } else {
        var url = "/profit/bapi/v1.9/platformp-rofit/";
      }

      var dates = {
        id: _this.itemData.id,
        commodityId: _this.itemData.commodityId,
        mallType: _this.itemData.mallType,
        amountlimit: _this.itemData.amountlimit,
        settingType: "COMMODITY",
      };

      // alert(JSON.stringify(dates))
      ajaxRequest(url, "PUT", "json", dates, function (ret, err) {
        layer.msg("设置成功");
        setTimeout(function () {
          var index = parent.layer.getFrameIndex(window.name);
          parent.layer.close(index);
          parent.location.reload();
        }, 1000);
      });
    },
    screens: function () {
      return screen();
    },
  },
  updated: function () {
    this.isShow = true;
    var _this = this;
    layui.use("form", function () {
      var form = layui.form;
      form.render();
    });
  },
};
</script>
<style scoped>
</style>